
 <!DOCTYPE HTML>
<html >
<head>
  <meta charset="UTF-8">
  
    <title>springboot应用关闭方式 | Typhoon&#39;s code space</title>
    <meta name="viewport" content="width=device-width, initial-scale=1,user-scalable=no">
    
    <meta name="author" content="typhoon">
    

    
    <meta name="description" content="在这篇文章中，我们将讨论使用不同的方式关闭Spring启动应用程序。">
<meta name="keywords" content="springboot">
<meta property="og:type" content="article">
<meta property="og:title" content="springboot应用关闭方式">
<meta property="og:url" content="http://scorpioaeolus.oschina.io/2018/11/24/springboot应用关闭方式/index.html">
<meta property="og:site_name" content="Typhoon&#39;s code space">
<meta property="og:description" content="在这篇文章中，我们将讨论使用不同的方式关闭Spring启动应用程序。">
<meta property="og:updated_time" content="2018-11-24T12:18:50.018Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="springboot应用关闭方式">
<meta name="twitter:description" content="在这篇文章中，我们将讨论使用不同的方式关闭Spring启动应用程序。">

    
    <link rel="alternative" href="/atom.xml" title="Typhoon&#39;s code space" type="application/atom+xml">
    
    
    <link rel="icon" href="/typhoon/img/java.png">
    
    
    <link rel="apple-touch-icon" href="/typhoon/img/jacman.jpg">
    <link rel="apple-touch-icon-precomposed" href="/typhoon/img/jacman.jpg">
    
    <link rel="stylesheet" href="/typhoon/css/style.css">
</head>

  <body>
    <header>
      
<div>
		
			<div id="imglogo">
				<a href="/typhoon/"><img src="/typhoon/img/java.png" alt="Typhoon&#39;s code space" title="Typhoon&#39;s code space"/></a>
			</div>
			
			<div id="textlogo">
				<h1 class="site-name"><a href="/typhoon/" title="Typhoon&#39;s code space">Typhoon&#39;s code space</a></h1>
				<h2 class="blog-motto"></h2>
			</div>
			<div class="navbar"><a class="navbutton navmobile" href="#" title="Menu">
			</a></div>
			<nav class="animated">
				<ul>
					<ul>
					 
						<li><a href="/typhoon/">主页</a></li>
					
						<li><a href="/typhoon/archives">归档</a></li>
					
						<li><a href="/typhoon/about">关于</a></li>
					
					<li>
 					
					<form class="search" action="//google.com/search" method="get" accept-charset="utf-8">
						<label>Search</label>
						<input type="search" id="search" name="q" autocomplete="off" maxlength="20" placeholder="Search" />
						<input type="hidden" name="q" value="site:scorpioaeolus.oschina.io">
					</form>
					
					</li>
				</ul>
			</nav>			
</div>
    </header>
    <div id="container">
      <div id="main" class="post" itemscope itemprop="blogPost">
  
	<article itemprop="articleBody"> 
		<header class="article-info clearfix">
  <h1 itemprop="name">
    
      <a href="/typhoon/2018/11/24/springboot应用关闭方式/" title="springboot应用关闭方式" itemprop="url">springboot应用关闭方式</a>
  </h1>
  <p class="article-author">By
       
		<a href="/typhoon/about" title="typhoon" target="_blank" itemprop="author">typhoon</a>
		
  <p class="article-time">
    <time datetime="2018-11-24T11:53:06.000Z" itemprop="datePublished"> Published 2018-11-24</time>
    
  </p>
</header>
	<div class="article-content">
		
		<div id="toc" class="toc-article">
			<strong class="toc-title">Contents</strong>
		
			<ol class="toc"><li class="toc-item toc-level-5"><a class="toc-link" href="#介绍"><span class="toc-number">1.</span> <span class="toc-text">介绍</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#1-使用Actuator端点关闭"><span class="toc-number">2.</span> <span class="toc-text">1.使用Actuator端点关闭</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#2-关闭ApplicationContext上下文"><span class="toc-number">3.</span> <span class="toc-text">2.关闭ApplicationContext上下文</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#3-使用SpringApplication-exit退出"><span class="toc-number">4.</span> <span class="toc-text">3.使用SpringApplication#exit退出</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#4-杀死应用进程"><span class="toc-number">5.</span> <span class="toc-text">4.杀死应用进程</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#总结"><span class="toc-number">6.</span> <span class="toc-text">总结</span></a></li></ol>
		
		</div>
		
		<pre><code>在这篇文章中，我们将讨论使用不同的方式关闭Spring启动应用程序。
</code></pre><a id="more"></a>
<h5 id="介绍"><a href="#介绍" class="headerlink" title="介绍"></a>介绍</h5><pre><code>    在生产环境中管理应用程序与开发环境不同。我们可能希望控制我们部署在生产环境的应用程序的生命周期。
SpringBoot提供了一些开箱即用的特性来控制Spring容器的生命周期，包括优雅地关闭SpringBoot应用程序。让
我们讨论一些最常见的方法来控制生产环境中的Springboot企业应用程序。
</code></pre><h5 id="1-使用Actuator端点关闭"><a href="#1-使用Actuator端点关闭" class="headerlink" title="1.使用Actuator端点关闭"></a>1.使用Actuator端点关闭</h5><pre><code>    springboot actuator具有许多生产就绪特征，包括 关闭端点。默认情况下，actuator中没有启用所有 关闭端点。
要在我们的应用程序中使用此端点，我们应该引用spring-boot-starter-actuator，并在应用程序中启用此端点。    

    为了引入和启用它，我们需要在应用程序pom.xml中添加spring-boot-starter-actuator启动器，并且需要使用
application.properties或application.yml文件启用关闭端点。下面是我们的Maven依赖项设置。
</code></pre><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">&lt;dependency&gt;</div><div class="line">    &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;</div><div class="line">    &lt;artifactId&gt;spring-boot-starter-actuator&lt;/artifactId&gt;</div><div class="line">&lt;/dependency&gt;</div></pre></td></tr></table></figure>
<pre><code>    如果要配置端点的启用，需要使用management.endpoint..enabled属性。下面就是我们的应用程序属性在添加
更改后的样子：
</code></pre><figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">management.endpoint.shutdown.enabled=<span class="keyword">true</span></div><div class="line">management.endpoint.info.enabled=<span class="keyword">true</span></div><div class="line">management.endpoints.web.exposure.include=*</div></pre></td></tr></table></figure>
<p><strong>1.1 安全端点</strong></p>
<pre><code>    在这个例子中，我们在没有任何安全防护的情况下开放 端点。不建议在生产应用程序上执行此操作。
这会给应用程序带来很大的安全风险。为了保护应用的的关闭端点，需要使用spring-boot-starter-security。
</code></pre><figure class="highlight"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">&lt;dependency&gt;</div><div class="line"></div><div class="line">  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;</div><div class="line"></div><div class="line">  &lt;artifactId&gt;spring-boot-starter-security&lt;/artifactId&gt;</div><div class="line"></div><div class="line">&lt;/dependency&gt;</div></pre></td></tr></table></figure>
<p><strong>1.2 测试端点</strong></p>
<pre><code>要测试关闭端点，需要先启动应用，当应用启动运行后，只需要调用使用POST方式调用端点即可。
</code></pre><figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">curl -i -X POST http:<span class="comment">//localhost:8080/actuator/shutdown</span></div></pre></td></tr></table></figure>
<pre><code>产生如下类似的响应：
</code></pre><figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div></pre></td><td class="code"><pre><div class="line">HTTP/<span class="number">1.1</span> <span class="number">200</span> </div><div class="line"></div><div class="line">Content-Type: application/vnd.spring-         boot.actuator.v2+json;charset=UTF-<span class="number">8</span></div><div class="line"></div><div class="line">Transfer-Encoding: chunked</div><div class="line"></div><div class="line">Date: Sun, <span class="number">05</span> Aug <span class="number">2018</span> <span class="number">18</span>:<span class="number">11</span>:<span class="number">27</span> GMT</div><div class="line"></div><div class="line"></div><div class="line"></div><div class="line">&#123;</div><div class="line"></div><div class="line">   <span class="string">"message"</span>:<span class="string">"Shutting down, bye..."</span></div><div class="line"></div><div class="line">&#125;</div></pre></td></tr></table></figure>
<pre><code>查看服务器控制台/日志，会看到类似的输出：
</code></pre><figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line"><span class="number">2018</span>-<span class="number">08</span>-<span class="number">05</span> <span class="number">11</span>:<span class="number">11</span>:<span class="number">28.151</span>  INFO <span class="number">9626</span> --- [      Thread-<span class="number">28</span>] ConfigServletWebServerApplicationContext : Closing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@<span class="number">42f</span>0c846: startup date [Sun Aug <span class="number">05</span> <span class="number">11</span>:<span class="number">10</span>:<span class="number">58</span> PDT <span class="number">2018</span>]; root of context hierarchy</div><div class="line"></div><div class="line"><span class="number">2018</span>-<span class="number">08</span>-<span class="number">05</span> <span class="number">11</span>:<span class="number">11</span>:<span class="number">28.155</span>  INFO <span class="number">9626</span> --- [      Thread-<span class="number">28</span>] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown</div></pre></td></tr></table></figure>
<h5 id="2-关闭ApplicationContext上下文"><a href="#2-关闭ApplicationContext上下文" class="headerlink" title="2.关闭ApplicationContext上下文"></a>2.关闭ApplicationContext上下文</h5><pre><code>    关闭Spring启动应用程序的另外一种方式是使用SpringApplication关闭ApplicationContext上下文。
SpringApplication#run(String...)方法返回ApplicationContext作为ConfigurableApplicationContext上下文。
我们可以调用close()方法以编程方式关闭ApplicationContext上下文。 
</code></pre><figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line"><span class="meta">@SpringBootApplication</span></div><div class="line"></div><div class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">SpringBootShutdownApplication</span> </span>&#123;</div><div class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</div><div class="line">  ConfigurableApplicationContext ctx = SpringApplication.run(SpringBootShutdownApplication.class, args);</div><div class="line">  ctx.close();</div><div class="line"> &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<pre><code>运行应用程序时，我们在服务器控制台或日志文件上有类似的输出：
</code></pre><figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line"><span class="number">2018</span>-<span class="number">08</span>-<span class="number">05</span> <span class="number">11</span>:<span class="number">32</span>:<span class="number">19.898</span>  INFO <span class="number">9899</span> --- [  restartedMain] ConfigServletWebServerApplicationContext : Closing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@<span class="number">72</span>d1ddb3: startup date [Sun Aug <span class="number">05</span> <span class="number">11</span>:<span class="number">32</span>:<span class="number">16</span> PDT <span class="number">2018</span>]; root of context hierarchy</div><div class="line"></div><div class="line"><span class="number">2018</span>-<span class="number">08</span>-<span class="number">05</span> <span class="number">11</span>:<span class="number">32</span>:<span class="number">19.901</span>  INFO <span class="number">9899</span> --- [  restartedMain] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown</div></pre></td></tr></table></figure>
<pre><code>要处理ApplicationContext上下文关闭事件，让我们使用@PreDestroy注解创建关闭处理方法：
</code></pre><figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line"><span class="meta">@Configuration</span></div><div class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">ApplicationConfig</span> </span>&#123;</div><div class="line"> <span class="meta">@PreDestroy</span></div><div class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">onShutDown</span><span class="params">()</span> </span>&#123;</div><div class="line">  System.out.println(<span class="string">"closing application context..let's do the final resource cleanup"</span>);</div><div class="line"> &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<pre><code>在运行应用程序时，我们看到类似的输出：
</code></pre><figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line"><span class="number">2018</span>-<span class="number">08</span>-<span class="number">05</span> <span class="number">22</span>:<span class="number">24</span>:<span class="number">48.487</span>  INFO <span class="number">10550</span> --- [  restartedMain] ConfigServletWebServerApplicationContext : Closing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@<span class="number">451</span>a9713: startup date [Sun Aug <span class="number">05</span> <span class="number">22</span>:<span class="number">24</span>:<span class="number">45</span> EDT <span class="number">2018</span>]; root of context hierarchy</div><div class="line"></div><div class="line"><span class="number">2018</span>-<span class="number">08</span>-<span class="number">05</span> <span class="number">22</span>:<span class="number">24</span>:<span class="number">48.490</span>  INFO <span class="number">10550</span> --- [  restartedMain] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown</div><div class="line"></div><div class="line">closing application context..let<span class="string">'s do the final resource cleanup</span></div></pre></td></tr></table></figure>
<h5 id="3-使用SpringApplication-exit退出"><a href="#3-使用SpringApplication-exit退出" class="headerlink" title="3.使用SpringApplication#exit退出"></a>3.使用SpringApplication#exit退出</h5><pre><code>我们还可以选择使用SpringApplication类可用的静态退出帮助方法：
</code></pre><figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div></pre></td><td class="code"><pre><div class="line"><span class="meta">@SpringBootApplication</span></div><div class="line"></div><div class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">SpringBootShutdownApplication</span> </span>&#123;</div><div class="line"></div><div class="line"></div><div class="line"></div><div class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</div><div class="line"></div><div class="line"></div><div class="line"></div><div class="line">  ConfigurableApplicationContext ctx = SpringApplication.run(SpringBootShutdownApplication.class, args);</div><div class="line"></div><div class="line">  exitApplication(ctx);</div><div class="line"></div><div class="line">  <span class="comment">//ctx.close();</span></div><div class="line"></div><div class="line"> &#125;</div><div class="line"></div><div class="line"></div><div class="line"></div><div class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">exitApplication</span><span class="params">(ConfigurableApplicationContext ctx)</span> </span>&#123;</div><div class="line"></div><div class="line">  <span class="keyword">int</span> exitCode = SpringApplication.exit(ctx, <span class="keyword">new</span> ExitCodeGenerator() &#123;</div><div class="line"></div><div class="line">   <span class="meta">@Override</span></div><div class="line"></div><div class="line">   <span class="function"><span class="keyword">public</span> <span class="keyword">int</span> <span class="title">getExitCode</span><span class="params">()</span> </span>&#123;</div><div class="line"></div><div class="line">    <span class="comment">// no errors</span></div><div class="line"></div><div class="line">    <span class="keyword">return</span> <span class="number">0</span>;</div><div class="line"></div><div class="line">   &#125;</div><div class="line"></div><div class="line">  &#125;);</div><div class="line"></div><div class="line">  System.exit(exitCode);</div><div class="line"></div><div class="line"> &#125;</div><div class="line"></div><div class="line">&#125;</div></pre></td></tr></table></figure>
<pre><code>用Java8的lambda表达式，上面的代码可以重写为：
</code></pre><figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">SpringApplication.exit(ctx, () -&gt; returnCode);</div></pre></td></tr></table></figure>
<h5 id="4-杀死应用进程"><a href="#4-杀死应用进程" class="headerlink" title="4.杀死应用进程"></a>4.杀死应用进程</h5><pre><code>使用springboot应用将进程id写入到文件中，我们可以通过一个bash脚本使用进程文件来停止和重启应用以及获取运行状态：
</code></pre><figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">SpringApplication application = <span class="keyword">new</span> SpringApplication(Application.class);</div><div class="line"></div><div class="line">application.addListeners(<span class="keyword">new</span> ApplicationPidFileWriter(<span class="string">"./bin/app.pid"</span>));</div><div class="line"></div><div class="line">application.run();</div></pre></td></tr></table></figure>
<h5 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h5><pre><code>    在这篇文章中，我们讨论了关闭springboot应用程序的不同方式，我们了解了在Springboot actuator下使用HTTP方式关闭应用
程序的shutdown端点。我们也分析了使用SpringAppication#close方法关闭应用程序上下文，在最后，我们了解了如何将进程id
写入文件，以及如何使用bash脚本来控制应用程序的生命周期。    
</code></pre>  
	</div>
		<footer class="article-footer clearfix">
<div class="article-catetags">

<div class="article-categories">
  <span></span>
  <a class="article-category-link" href="/typhoon/categories/springboot/">springboot</a>
</div>


  <div class="article-tags">
  
  <span></span> <a href="/typhoon/tags/springboot/">springboot</a>
  </div>

</div>



	<div class="article-share" id="share">
	
	  <div data-url="http://scorpioaeolus.oschina.io/2018/11/24/springboot应用关闭方式/" data-title="springboot应用关闭方式 | Typhoon&#39;s code space" data-tsina="null" class="share clearfix">
	  </div>
	
	</div>


</footer>

   	       
	</article>
	
<nav class="article-nav clearfix">
 
 <div class="prev" >
 <a href="/typhoon/2018/11/24/springboot之CommandLineRunner接口/" title="springboot之CommandLineRunner接口">
  <strong>上一篇：</strong><br/>
  <span>
  springboot之CommandLineRunner接口</span>
</a>
</div>


<div class="next">
<a href="/typhoon/2018/11/18/springboot-19-security/"  title="springboot(19)-security">
 <strong>下一篇：</strong><br/> 
 <span>springboot(19)-security
</span>
</a>
</div>

</nav>

	


</div>  
      <div class="openaside"><a class="navbutton" href="#" title="Show Sidebar"></a></div>

  <div id="toc" class="toc-aside">
  <strong class="toc-title">Contents</strong>
 
 <ol class="toc"><li class="toc-item toc-level-5"><a class="toc-link" href="#介绍"><span class="toc-number">1.</span> <span class="toc-text">介绍</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#1-使用Actuator端点关闭"><span class="toc-number">2.</span> <span class="toc-text">1.使用Actuator端点关闭</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#2-关闭ApplicationContext上下文"><span class="toc-number">3.</span> <span class="toc-text">2.关闭ApplicationContext上下文</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#3-使用SpringApplication-exit退出"><span class="toc-number">4.</span> <span class="toc-text">3.使用SpringApplication#exit退出</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#4-杀死应用进程"><span class="toc-number">5.</span> <span class="toc-text">4.杀死应用进程</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#总结"><span class="toc-number">6.</span> <span class="toc-text">总结</span></a></li></ol>
 
  </div>

<div id="asidepart">
<div class="closeaside"><a class="closebutton" href="#" title="Hide Sidebar"></a></div>
<aside class="clearfix">

  


  
<div class="categorieslist">
	<p class="asidetitle">Categories</p>
		<ul>
		
		  
			<li><a href="/typhoon/categories/dubbo/" title="dubbo">dubbo<sup>8</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/java性能优化/" title="java性能优化">java性能优化<sup>17</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/java源码分析/" title="java源码分析">java源码分析<sup>1</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/motan/" title="motan">motan<sup>2</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/spring/" title="spring">spring<sup>11</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/springboot/" title="springboot">springboot<sup>28</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/springmvc/" title="springmvc">springmvc<sup>1</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/容器/" title="容器">容器<sup>1</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/工具/" title="工具">工具<sup>7</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/性能优化/" title="性能优化">性能优化<sup>5</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/架构/" title="架构">架构<sup>8</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/案例分析/" title="案例分析">案例分析<sup>13</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/缓存/" title="缓存">缓存<sup>4</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/设计模式/" title="设计模式">设计模式<sup>3</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/面试题/" title="面试题">面试题<sup>1</sup></a></li>
		  
		
		</ul>
</div>


  
<div class="tagslist">
	<p class="asidetitle">Tags</p>
		<ul class="clearfix">
		
			
				<li><a href="/typhoon/tags/springboot/" title="springboot">springboot<sup>28</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/java性能优化/" title="java性能优化">java性能优化<sup>9</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/限流/" title="限流">限流<sup>3</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/Spring5/" title="Spring5">Spring5<sup>3</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/设计模式/" title="设计模式">设计模式<sup>3</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/案例分析/" title="案例分析">案例分析<sup>2</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/性能优化/" title="性能优化">性能优化<sup>2</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/Spring/" title="Spring">Spring<sup>2</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/dubbo/" title="dubbo">dubbo<sup>2</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/分页/" title="分页">分页<sup>2</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/并发/" title="并发">并发<sup>2</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/异常拦截/" title="异常拦截">异常拦截<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/dubbo分布式事务/" title="dubbo分布式事务">dubbo分布式事务<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/自带图片/" title="自带图片">自带图片<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/svn导出mvn项目/" title="svn导出mvn项目">svn导出mvn项目<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/dubbo过滤器/" title="dubbo过滤器">dubbo过滤器<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/排序性能对比/" title="排序性能对比">排序性能对比<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/ListenableFuture/" title="ListenableFuture">ListenableFuture<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/PropertyChangeListener/" title="PropertyChangeListener">PropertyChangeListener<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/jdbcTemplate高可用/" title="jdbcTemplate高可用">jdbcTemplate高可用<sup>1</sup></a></li>
			
		
		</ul>
</div>


  <div class="linkslist">
  <p class="asidetitle">Links</p>
    <ul>
        
          <li>
            
            	<a href="https://coderq.com" target="_blank" title="一个面向程序员交流分享的新一代社区">码农圈</a>
            
          </li>
        
          <li>
            
            	<a href="http://wuchong.me" target="_blank" title="Jark&#39;s Blog">Jark&#39;s Blog</a>
            
          </li>
        
    </ul>
</div>

  


  <div class="rsspart">
	<a href="/atom.xml" target="_blank" title="rss">RSS</a>
</div>

  <div class="weiboshow">
  <p class="asidetitle">Weibo</p>
    <iframe width="100%" height="119" class="share_self"  frameborder="0" scrolling="no" src="http://widget.weibo.com/weiboshow/index.php?language=&width=0&height=119&fansRow=2&ptype=1&speed=0&skin=9&isTitle=1&noborder=1&isWeibo=0&isFans=0&uid=null&verifier=b3593ceb&dpc=1"></iframe>
</div>


</aside>
</div>
    </div>
    <footer><div id="footer" >
	
	<div class="line">
		<span></span>
		<div class="author"></div>
	</div>
	
	
	<section class="info">
		<p> Hello ,I&#39;m a java coder. <br/>
			This is my blog,believe it or not.</p>
	</section>
	 
	<div class="social-font" class="clearfix">
		
		
		
		
		
		
		
		
		
		
		<a href="mailto:ScorpioAeolus@163.com" target="_blank" class="icon-email" title="Email Me"></a>
		
	</div>
			
		

		<p class="copyright">
		Powered by <a href="http://hexo.io" target="_blank" title="hexo">hexo</a> and Theme by <a href="https://github.com/wuchong/jacman" target="_blank" title="Jacman">Jacman</a> © 2019 
		
		<a href="/typhoon/about" target="_blank" title="typhoon">typhoon</a>
		
		
		</p>
</div>
</footer>
    <script src="/typhoon/js/jquery-2.0.3.min.js"></script>
<script src="/typhoon/js/jquery.imagesloaded.min.js"></script>
<script src="/typhoon/js/gallery.js"></script>
<script src="/typhoon/js/jquery.qrcode-0.12.0.min.js"></script>

<script type="text/javascript">
$(document).ready(function(){ 
  $('.navbar').click(function(){
    $('header nav').toggleClass('shownav');
  });
  var myWidth = 0;
  function getSize(){
    if( typeof( window.innerWidth ) == 'number' ) {
      myWidth = window.innerWidth;
    } else if( document.documentElement && document.documentElement.clientWidth) {
      myWidth = document.documentElement.clientWidth;
    };
  };
  var m = $('#main'),
      a = $('#asidepart'),
      c = $('.closeaside'),
      o = $('.openaside');
  c.click(function(){
    a.addClass('fadeOut').css('display', 'none');
    o.css('display', 'block').addClass('fadeIn');
    m.addClass('moveMain');
  });
  o.click(function(){
    o.css('display', 'none').removeClass('beforeFadeIn');
    a.css('display', 'block').removeClass('fadeOut').addClass('fadeIn');      
    m.removeClass('moveMain');
  });
  $(window).scroll(function(){
    o.css("top",Math.max(80,260-$(this).scrollTop()));
  });
  
  $(window).resize(function(){
    getSize(); 
    if (myWidth >= 1024) {
      $('header nav').removeClass('shownav');
    }else{
      m.removeClass('moveMain');
      a.css('display', 'block').removeClass('fadeOut');
      o.css('display', 'none');
      
      $('#toc.toc-aside').css('display', 'none');
        
    }
  });
});
</script>

<script type="text/javascript">
$(document).ready(function(){ 
  var ai = $('.article-content>iframe'),
      ae = $('.article-content>embed'),
      t  = $('#toc'),
      ta = $('#toc.toc-aside'),
      o  = $('.openaside'),
      c  = $('.closeaside');
  if(ai.length>0){
    ai.wrap('<div class="video-container" />');
  };
  if(ae.length>0){
   ae.wrap('<div class="video-container" />');
  };
  c.click(function(){
    ta.css('display', 'block').addClass('fadeIn');
  });
  o.click(function(){
    ta.css('display', 'none');
  });
  $(window).scroll(function(){
    ta.css("top",Math.max(140,320-$(this).scrollTop()));
  });
});
</script>


<script type="text/javascript">
$(document).ready(function(){ 
  var $this = $('.share'),
      url = $this.attr('data-url'),
      encodedUrl = encodeURIComponent(url),
      title = $this.attr('data-title'),
      tsina = $this.attr('data-tsina'),
      description = $this.attr('description');
  var html = [
  '<div class="hoverqrcode clearfix"></div>',
  '<a class="overlay" id="qrcode"></a>',
  '<a href="https://www.facebook.com/sharer.php?u=' + encodedUrl + '" class="article-share-facebook" target="_blank" title="Facebook"></a>',
  '<a href="https://twitter.com/intent/tweet?url=' + encodedUrl + '" class="article-share-twitter" target="_blank" title="Twitter"></a>',
  '<a href="#qrcode" class="article-share-qrcode" title="微信"></a>',
  '<a href="http://widget.renren.com/dialog/share?resourceUrl=' + encodedUrl + '&srcUrl=' + encodedUrl + '&title=' + title +'" class="article-share-renren" target="_blank" title="人人"></a>',
  '<a href="http://service.weibo.com/share/share.php?title='+title+'&url='+encodedUrl +'&ralateUid='+ tsina +'&searchPic=true&style=number' +'" class="article-share-weibo" target="_blank" title="微博"></a>',
  '<span title="Share to"></span>'
  ].join('');
  $this.append(html);

  $('.hoverqrcode').hide();

  var myWidth = 0;
  function updatehoverqrcode(){
    if( typeof( window.innerWidth ) == 'number' ) {
      myWidth = window.innerWidth;
    } else if( document.documentElement && document.documentElement.clientWidth) {
      myWidth = document.documentElement.clientWidth;
    };
    var qrsize = myWidth > 1024 ? 200:100;
    var options = {render: 'image', size: qrsize, fill: '#2ca6cb', text: url, radius: 0.5, quiet: 1};
    var p = $('.article-share-qrcode').position();
    $('.hoverqrcode').empty().css('width', qrsize).css('height', qrsize)
                          .css('left', p.left-qrsize/2+20).css('top', p.top-qrsize-10)
                          .qrcode(options);
  };
  $(window).resize(function(){
    $('.hoverqrcode').hide();
  });
  $('.article-share-qrcode').click(function(){
    updatehoverqrcode();
    $('.hoverqrcode').toggle();
  });
  $('.article-share-qrcode').hover(function(){}, function(){
      $('.hoverqrcode').hide();
  });
});   
</script>









<link rel="stylesheet" href="/typhoon/fancybox/jquery.fancybox.css" media="screen" type="text/css">
<script src="/typhoon/fancybox/jquery.fancybox.pack.js"></script>
<script type="text/javascript">
$(document).ready(function(){ 
  $('.article-content').each(function(i){
    $(this).find('img').each(function(){
      if ($(this).parent().hasClass('fancybox')) return;
      var alt = this.alt;
      if (alt) $(this).after('<span class="caption">' + alt + '</span>');
      $(this).wrap('<a href="' + this.src + '" title="' + alt + '" class="fancybox"></a>');
    });
    $(this).find('.fancybox').each(function(){
      $(this).attr('rel', 'article' + i);
    });
  });
  if($.fancybox){
    $('.fancybox').fancybox();
  }
}); 
</script>



<!-- Analytics Begin -->



<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "//hm.baidu.com/hm.js?e6d1f421bbc9962127a50488f9ed37d1";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>



<!-- Analytics End -->

<!-- Totop Begin -->

	<div id="totop">
	<a title="Back to Top"><img src="/typhoon/img/scrollup.png"/></a>
	</div>
	<script src="/typhoon/js/totop.js"></script>

<!-- Totop End -->

<!-- MathJax Begin -->
<!-- mathjax config similar to math.stackexchange -->


<!-- MathJax End -->

<!-- Tiny_search Begin -->

<!-- Tiny_search End -->

  </body>
</html>
